﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdbRegisterTool
{
    using System;

    public class AddrHelp
    {
        // 私有字段，通过公共属性访问  
        private uint _address;
        private uint _baseAddr;
        private uint _data;
        private string _note;
        private string _id;
        private string _readNO;
        private string _writeNO;

        public string WriteNo
        {
            get => _writeNO;
            set => _writeNO = value;
        }

        public string ReadNO
        {

            get => _readNO;
            set => _readNO = value;
        }
        public string ID
        {
            get => _id;
            set => _id = value;
        }

        /// <summary>  
        /// 地址  
        /// </summary>  
        public uint Address
        {
            get => _address;
            set => _address = value;
        }

        /// <summary>  
        /// 基地址  
        /// </summary>  
        public uint BaseAddr
        {
            get => _baseAddr;
            set => _baseAddr = value;
        }

        /// <summary>  
        /// 值  
        /// </summary>  
        public uint Data
        {
            get => _data;
            set => _data = value;
        }

        /// <summary>  
        /// 说明  
        /// </summary>  
        public string Note
        {
            get => _note;
            set => _note = value;
        }

        /// <summary>  
        /// 构造函数，用于初始化对象  
        /// </summary>  
        /// <param name="address">地址</param>  
        /// <param name="baseAddr">基地址</param>  
        /// <param name="data">值</param>  
        /// <param name="note">说明</param>  
        public AddrHelp(uint address, uint data, string note="")
        {
            _address = address;
            _data = data;
            _note = note;
        }

        /// <summary>  
        /// 输出正确的地址（由基地址和地址组成）  
        /// </summary>  
        public string Addr
        {
            get
            {
                return $"{(BaseAddr&0xffff).ToString("X4")}{(Address&0xffff).ToString("X4")}";
            }
        }

        /// <summary>
        /// 获取指令
        /// </summary>
        public string GetCommand
        {
            get
            {
                return $"adb shell setprop vendor.extcamera.xxw.ispregctrl  \"{ReadNO},{Addr},{Data.ToString("X2")},{ID}\"";
            }
        }
        /// <summary>
        /// 设置指令
        /// </summary>
        public string SetCommand
        {
            get
            {
                return $"adb shell setprop vendor.extcamera.xxw.ispregctrl  \"{WriteNo},{Addr},{Data.ToString("X2")},{ID}\"";
            }
        }

    }




    public class SensorHelp
    {
        private uint _address;
        private uint _data;
        private string _id;
        private string _readNO;
        private string _writeNO;
        public string WriteNo
        {
            get => _writeNO;
            set => _writeNO = value;
        }

        public string ReadNO
        {

            get => _readNO;
            set => _readNO = value;
        }
        public string ID
        {
            get => _id;
            set => _id = value;
        }

        /// <summary>  
        /// 地址  
        /// </summary>  
        public uint Address
        {
            get => _address;
            set => _address = value;
        }

  

        /// <summary>  
        /// 值  
        /// </summary>  
        public uint Data
        {
            get => _data;
            set => _data = value;
        }

   

        /// <summary>  
        /// 构造函数，用于初始化对象  
        /// </summary>  
        /// <param name="address">地址</param>  
        /// <param name="baseAddr">基地址</param>  
        /// <param name="data">值</param>  
        /// <param name="note">说明</param>  
        public SensorHelp(uint address, uint data, string note = "")
        {
            _address = address;
            _data = data;
        }

     

        /// <summary>
        /// 获取指令
        /// </summary>
        public string GetCommand
        {
            get
            {
                return $"adb shell setprop vendor.extcamera.xxw.ispregctrl  \"{ReadNO},{Address.ToString("X4")},{Data.ToString("X2")},{ID}\"";
            }
        }
        /// <summary>
        /// 设置指令
        /// </summary>
        public string SetCommand
        {
            get
            {
                return $"adb shell setprop vendor.extcamera.xxw.ispregctrl  \"{WriteNo},{Address.ToString("X4")},{Data.ToString("X2")},{ID}\"";
            }
        }
    }
}
